package edu.sctu.yueding.activitys;

import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import edu.sctu.yueding.R;
import edu.sctu.yueding.utils.JumpUtils;
import edu.sctu.yueding.view.CustomDialog;


/**
 * Created by fll on 2016/8/3.
 */
public class ActivityInformationActivity extends BaseActivity {

    private ImageView mBackButton;
    private Button mSignInButton;
    private CustomDialog.Builder builder;
    private WebView webView;
    public static int MATCH_END = 0;
    public static int MATCH_NO_END = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_information);

        initView();
        initSystemBar(this, R.color.top_bac);
    }

    private void initView() {
        mBackButton = (ImageView) findViewById(R.id.activity_information_back_botton);
        mBackButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        mSignInButton = (Button) findViewById(R.id.activity_information_signIn_button);



        if (getIntent().getExtras().getInt("endTag") == MATCH_END){

            mSignInButton.setBackgroundResource(R.drawable.baoming_end);

        }else {
            mSignInButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    boolean flag = JumpUtils.isLogin(ActivityInformationActivity.this);
                    if (flag == false) {
                        Toast.makeText(ActivityInformationActivity.this, "请先登录！", Toast.LENGTH_LONG).show();
                    } else {

                        JumpUtils.jumpActivity(ActivityInformationActivity.this, ProtocolActivity.class);

                    }
                }
            });
        }


        initWebView();
    }

    private void initWebView() {

        webView = (WebView) findViewById(R.id.activity_information_webView);
        String content = getIntent().getExtras().getString("matchContent");
        webView.loadUrl(content);

        webView.setWebChromeClient(new WebChromeClient() {
        });

        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.loadUrl(url);
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
    }


}
